Many physical documents have suffered damage, for example due to exposure to water or moisture. People have tried to edit scanned images of damaged documents to improve the appearance of the documents using various software tools but the quality of such restoration efforts is generally unsatisfactory especially with respect to text and writing in the documents. For example, photo editing software applications generally do not satisfactorily repair the appearance of scanned documents containing printed or written writings.